<?php

// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: create by allen.qiang
// +----------------------------------------------------------------------

/**
 * 短信邮件自定义模板
 * @package  htdocs
 * @subpackage  quanliadmin
 * @author   create by allen.qiang
 */

quanli_require('module/base/system/sysMessageTemplate.class.php');

class pa_messageTemplate {

    public function execute() {

        global $G_PGLOB;

        if (isset($_REQUEST['operFlg']) && $_REQUEST['operFlg'] > 0) {

            switch ($_REQUEST['operFlg']) {

                case 1: //显示列表页面
                    $this->messageTemplateList();
                    break;

                case 2: //添加自定义模板
                    $this->messageTemplateAdd();
                    break;
                case 3: //编辑自定义模板
                    $this->messageTemplateEdit();
                    break;

                default:
                    $G_PGLOB->smarty->assign('msg', '参数错误，请审核后再操作');
                    $G_PGLOB->smarty->display('comm/error.tpl');
            }
        }
    }

    /**
     * 显示列表页面
     */
    private function messageTemplateList() {

        global $G_PGLOB;
        $G_PGLOB->smarty->display('system/messageTemplate.tpl');
    }


    /*
     * 新增自定义模板页面
     *
     * */
    private function messageTemplateAdd(){
        global $G_PGLOB;
        $operFlg = 2;
        $G_PGLOB->smarty->assign('operFlg',$operFlg);
        $G_PGLOB->smarty->display('system/messageTemplateAdd.tpl');
    }

    /*
     *
     * 编辑自定义模板
     */
    private function messageTemplateEdit(){

        global $G_PGLOB;

        //实例自定义模板类
        $sysMessageTemplate = new sysMessageTemplate($G_PGLOB->DBCA);

        $arg_array = array(
            'templateID'=>$_REQUEST['templateID']
        );
        //查找模板数据
        $item_array = $sysMessageTemplate->search( $arg_array ) ;

        $operFlg = 3;
        $G_PGLOB->smarty->assign('operFlg',$operFlg);
        $G_PGLOB->smarty->assign('templateMsg',$item_array[0]);
        $G_PGLOB->smarty->display('system/messageTemplateAdd.tpl');
    }
}
